<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| 后台路由 API Routes
|--------------------------------------------------------------------------
|
*/

Route::get('/wx', function (){
    return \App\Http\Controllers\Controller::wx();
});


//登入
Route::post('/login', 'Guest@login');
Route::post('/reg', 'Guest@reg');
//http://blog.martin.net/api/captcha
Route::get('/captcha', 'Guest@captcha');



#全局参数
Route::get('/config', function (){
    return \App\Http\Controllers\Controller::config();
});



//
//Route::middleware('auth:api')->get('/user', function (Request $request) {
//    return $request->user();
//});

//废弃
Route::middleware('auth:api')->group(function () {

//    Route::prefix('user')->group(function() {
//        Route::get('userInfo', 'User@userinfo');
//    });
//    Route::get('user', 'User@list');
//    Route::get('user/userInfo', 'User@userInfo');
//    Route::get('product', 'Product@list');
//    Route::post('product/save', 'Product@save');
//    Route::get('product/detail', 'Product@detail');

//    Route::post('post/save', 'PostCtrl@save');

});

# 用户信息
Route::prefix('me')
//    ->middleware(['admin.jwt'])     //中间件
    ->group(function () {
        Route::get('info', 'Me@info');
        Route::post('info/save', 'Me@saveInfo');
        Route::post('info/uploadImg', 'Me@uploadImg');

    });



#商品模块
Route::prefix('product')
//    ->middleware(['admin.jwt'])     //中间件
    ->namespace('Product')
    ->group(function () {
        Route::get('/', 'Product@search');
        Route::get('/export', 'Product@export');

        //商品详情
        Route::prefix('detail')
            ->group(function (){
                Route::get('/', 'Product@detail');
                Route::post('save', 'Product@save');
                Route::post('saveAttribute', 'Product@saveAttribute');
                Route::post('uploadImgLocal', 'Product@uploadImgLocal');
                Route::post('uploadImgUpyun', 'Product@uploadImgUpyun');
            });

        // 产品扩展属性模块
        Route::prefix('attribute')
            ->group(function (){
                Route::get('/', 'Attribute@ls');
                Route::get('detail', 'Attribute@detail');
                Route::post('save', 'Attribute@save');
//                Route::post('saveItem', 'Attribute@saveItem');
                Route::delete('delete', 'Attribute@delete');
            });
    });



Route::prefix('wms')
//    ->middleware(['admin.jwt'])     //中间件
    ->namespace('WMS')
    ->group(function () {
        # 仓库模块
        Route::prefix('warehouse')
            ->group(function () {
                Route::get('/', 'Warehouse@ls'); // 仓库列表
                Route::post('save', 'Warehouse@save'); // 仓库列表
            });
    });


Route::prefix('purchase')
//    ->middleware(['admin.jwt'])     //中间件
    ->namespace('Purchase')
    ->group(function () {
        # 仓库模块
        Route::Resource('vendor', 'Vendor' ); #Resource 模式
        /*Route::prefix('vendor')
            ->group(function () {
                Route::get('/', 'Vendor@ls');
                Route::get('detail', 'Vendor@detail');
                Route::post('detail/save', 'Vendor@save');
            });*/
    });


# 资源
Route::prefix('resource')
//    ->middleware(['admin.jwt'])     //中间件
    ->namespace('Resource')
    ->group(function () {
        Route::get('qiniu/token', 'Qiniu@token');


    });


